import { ref } from "vue";
import { useI18n } from "vue-i18n";

export function useLanguage() {
    const { locale, t } = useI18n();
    //切换语言
    const toggleLang = () => {
        if (locale.value == "zh-CN") {
            locale.value = "en-US";
        } else {
            locale.value = "zh-CN";
        }
    };

    // 获取当前语言
    const getLanguage = () => locale.value;

    return {
        locale,
        toggleLang,
        getLanguage,
        t,
    };
}
